package com.app.start;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * Hello world!
 *
 */
@SpringBootApplication
@RestController
@ComponentScan("com.app")
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        SpringApplication.run(App.class,args);
    }

    @RequestMapping("/hello")
    public String  hello(){
        return "hi es@";
    }

//    public static void es(){
//        byte[] addr = new byte[]{127,0,0,1};
//        TransportClient client= null;
//        try {
//             client = new PreBuiltTransportClient(Settings.EMPTY)
//                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByAddress(addr), 9300));
//            client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByAddress(addr), 9300));
//        } catch (UnknownHostException e) {
//            e.printStackTrace();
//        }
////        client.addTransportAddress()
////        TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
////                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByAddress(addr), 9300));
//        JSONObject jsonObject= new JSONObject();
//        jsonObject.put("user","mytest5");
//        //      jsonObject.put("postDate",new Date());日期直接使用有格式的问题。
//        jsonObject.put("message","mymessage5");
//        JSONArray jsonArray = new JSONArray();
//        jsonArray.add("test41");
//        jsonArray.add("test42");
//        jsonObject.put("testarray", jsonArray);
//        String message = jsonObject.toString();
//        IndexResponse response = client.prepareIndex("mmm", "ttt", "1").setSource(message).get();
//        GetResponse response2 = client.prepareGet("mmm", "ttt", "1").get();
//        String strTmp2 = response2.toString();
//        System.out.println("strTmp2="+strTmp2);
//        client.close();
//    }
}
